package LC;

/**
 * @ClassName lc42
 * @Description: TODO
 * @Author hl
 * @Date 2021/4/26
 * @Version V1.0
 **/
public class LC42 {
    public static int trap1(int[] height) {
        int res=0;
        for(int i=1;i<height.length-1;i++){
            int max_left=0,max_right=0;
            for(int j=i;j>=0;j--){
                max_left=Math.max(max_left,height[j]);//寻找左边最大的
            }
            for(int j=i;j<height.length;j++){
                max_right=Math.max(max_right,height[j]);//寻找右边最大的
            }
            res+=Math.min(max_left,max_right)-height[i];
        }
        return res;
    }
    public static int trap(int[] height) {
        int res=0;
        int n=height.length;
        int []maxLeft=new int[n];
        int []maxRight=new int[n];
        for(int i=0;i<height.length;i++){

        }
        return res;
    }

    public static void main(String[] args) {
        int []height = {0,1,0,2,1,0,1,3,2,1,2,1};
        System.out.println(trap(height));
    }
}
